package com.lanou.service;

import com.lanou.bean.AdminInfo;
import com.lanou.mapper.AdminInfoMapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by lanouhn on 17/10/17.
 */
@Service("AdminService")
public class AdminServiceImpl implements AdminService{

    @Autowired
    private AdminInfoMapper adminInfoMapper;

    @Override
    public AdminInfo selectAdmin(AdminInfo adminInfo) {
        return this.adminInfoMapper.selectAdmin(adminInfo);
    }

    @Override
    public List<Integer> selectRoleIdById(Integer admin_id) {
        return adminInfoMapper.selectRoleIdById(admin_id);
    }

    @Override
    public String selectroleNameById(Integer cost_id) {
        return adminInfoMapper.selectroleNameById(cost_id);
    }

    @Override
    public List<AdminInfo> selectAllAdmin() {
        return adminInfoMapper.selectAllAdmin();
    }




    @Override
    public int insertAdmin(String name, String usernum, String password, String telnum, String email) {
        return adminInfoMapper.insertAdmin(name,usernum,password,telnum,email);
    }

    @Override
    public int selectIdByname(String admin_code) {
        return adminInfoMapper.selectIdByname(admin_code);
    }


    @Override
    public int getId(String name) {
        return adminInfoMapper.getId(name);
    }

    @Override
    public int insertAdminRole(Integer admin_id, Integer role_id) {
        return adminInfoMapper.insertAdminRole(admin_id,role_id);
    }

    @Override
    public List<String> selectRoleList() {
        return adminInfoMapper.selectRoleList();
    }


    @Override
    public int deleteAdmin(Integer admin_id) {
        return adminInfoMapper.deleteAdmin(admin_id);
    }

    @Override
    public List<Integer> getRoleId(Integer admin_id) {
        return adminInfoMapper.getRoleId(admin_id);
    }

    @Override
    public int deleteByRoelId(Integer role_id) {
        return adminInfoMapper.deleteroleByRoleId(role_id);
    }

    @Override
    public int deleteAdminroleInfo(Integer admin_id) {
        return adminInfoMapper.deleteAdminRoleInfo(admin_id);
    }


    @Override
    public AdminInfo selectAdminInfoById(Integer admin_id) {
        System.out.println("service层"+admin_id);
        return adminInfoMapper.selectAdminInfoById(admin_id);
    }

    @Override
    public int updateAdminInfoById(Integer admin_id, String admin_code, String name, String telephone, String email) {
        return adminInfoMapper.updateAdminInfoById(admin_id,admin_code,name,telephone,email);
    }

    @Override
    public int updateSave(@Param("admin_id") Integer admin_id, @Param("name") String name, @Param("telephone") String telephone, @Param("email") String email) {
        return adminInfoMapper.updateSave(admin_id,name,telephone,email);
    }

    @Override
    public List<Integer> selectAdminId() {
        return adminInfoMapper.selectAdminId();
    }

    @Override
    public int updatepassword(Integer admin_id,String password) {
        return adminInfoMapper.updatepassword(admin_id,password);
    }
}
